<!DOCTYPE html>
<html class="x-admin-sm">
<#include "../layout/meta.ftl">
<body class="layui-layout-body">
<div style="margin: 2vw">

    <#if swarm??>
        <button type="button" id="addNode" class="layui-btn layui-btn-normal">添加集群节点</button>
        <a href="/swarm/disbandCluster" class="layui-btn layui-btn-danger">解散集群</a>
        <button class="layui-btn layui-btn-danger" onclick="updateUrl()">离开集群</button>
        <table class="layui-table">
            <colgroup>
                <col width="150">
                <col width="200">
            </colgroup>
            <thead>
            <tr>
                <th>类型</th>
                <th>token</th>
            </tr>
            </thead>
            <tbody>
            <tr>
                <td>manager</td>
                <td>${swarm.joinTokens.manager}</td>
            </tr>
            <tr>
                <td>worker</td>
                <td>${swarm.joinTokens.worker}</td>
            </tr>
            </tbody>
        </table>
    <#else>
           <button type="button" id="init" class="layui-btn layui-btn-normal">初始化Master节点</button>
    </#if>



</div>
<script>
    //JavaScript代码区域
    layui.use('element', function () {
        let element = layui.element;
        $("#init").click(function () {
            xadmin.open('初始化Master节点', '/swarm/init', 500, 200);
        });

        $("#addNode").click(function () {
            xadmin.open('添加节点', '/swarm/addNode');
        });
    });

    function updateUrl() {
        xadmin.open('选择docker', '/swarm/removeNode');
    }
</script>
</body>
</html>